{template paome_header}
<style type="text/css">
    td { text-align:center;}
</style>
<link rel="stylesheet" href="static/calendar/js/calendar.css" />
<script type="text/javascript" charset="utf-8" src="static/calendar/calendar.php"></script>

<h4 style="padding-left:10px;;">
    <span>曾经推荐过的用户</span>
</h4>

    <form class="form-horizontal" method="post" action="?c=paome_hall&a=hallUserHistory">
    <div class="control-group search-group" style="margin:0;">
        <label class="control-label">用户昵称：</label>
        <div class="controls">
          <input type="text" placeholder="用户昵称" name="nick_name" value="{$search['nick_name']}">
        </div>
    </div>

    <div class="control-group search-group" style="margin:0;">
        <div class="controls">
            <input type="hidden" value="search" name="s">
            <button class="btn" type="submit">搜索</button>
        </div>
    </div>
</form>
<hr/>
  <table class="table table-striped">
    <thead>
      <th width="80">名称</th>
      <th width="70">头像</th>
      <th width="100">开始时间</th>
      <th width="100">结束时间</th>
      <th width="100">竞赛阶段</th>
      <th width="100">推荐原因</th>
      <th width="90">操作</th>
    </thead>
    <tbody>
      {if !$setList}  
            <tr>
                <td colspan="8">暂无记录</td>
            </tr>
      {else}
      {loop $setList $k $menu}
      <tr>
        <td><input type="text" style="display:none;" name="nick_name_{$menu['uid']}" value="{$menu['nick_name']}"/>{$menu['nick_name']}</td>
        <td><input type="text" style="display:none;" name="header_{$menu['uid']}" value="{$menu['header']}"/><img width="50" src="{$menu['header']}"></td>
        <td>
          开始时间：<input type="text" name="start_time_{$menu['uid']}" readonly="readonly" id="start_time_id_{$menu['uid']}" value="{eval echo date('Y-m-d H:i:s', $menu['start_time'])}">
          <input name="start_time_btn" type="button" id="start_time_btn" onclick="return showCalendar('start_time_id_{$menu['uid']}', '%Y-%m-%d %H:%M:%S', '24', false, 'start_time_btn');" value="选择" class="button"/>
        </td>
        <td>
          结束时间：<input type="text" name="end_time_{$menu['uid']}" readonly="readonly" id="end_time_id_{$menu['uid']}" value="{eval echo date('Y-m-d H:i:s', $menu['end_time'])}">
          <input name="end_time_btn" type="button" id="end_time_btn" onclick="return showCalendar('end_time_id_{$menu['uid']}', '%Y-%m-%d %H:%M:%S', '24', false, 'end_time_btn');" value="选择" class="button""/>
        </td>
        <td>暂无</td>
        <td><input type="text" name="reason_{$menu['uid']}" value="{$menu['reason']}"></td>
        <td><a data-id="$menu['uid']" onclick="recomagain(this)">再次推荐</a></td>
        <td><input type="text" name="uid" value="{$menu['uid']}" style="display:none;"></td>
        <td><input type="text" name="cid_{$menu['uid']}" value="{$menu['id']}" style="display:none;"></td>
        <input type="text" name="startTime_{$menu['uid']}" style="display:none;" value="{eval echo date('Y-m-d H:i:s', $menu['start_time'])}">
        <input type="text" name="endTime_{$menu['uid']}" style="display:none;"s value="{eval echo date('Y-m-d H:i:s', $menu['end_time'])}">
      </tr>
      {/loop}
      {/if}
    </tbody>
  </table>
  <div class="pagination">
      <ul>
          {$pageStr}
      </ul>
  </div>

<script>
  function recomagain(obj){
      var mid = $(obj).attr('data-id');
      console.info(mid);
      var nick_name = $('[name=nick_name_'+mid+']').val();
      var header = $('[name=header_'+mid+']').val();
      var start_time = $('[name=start_time_'+mid+']').val();
      var end_time = $('[name=end_time_'+mid+']').val();
      var reason = $('[name=reason_'+mid+']').val();
      var cid = $('[name=cid_'+mid+']').val();
      //之前的时间
      var startTime = $('[name=startTime_'+mid+']').val();
      var endTime = $('[name=endTime_'+mid+']').val();
      
      if(start_time == startTime && end_time == endTime){
        alert("请调整时间后确认推荐");
        return false;
      }
      $.ajax({
          type:'POST',
          url:'?c=paome_hall&a=hallUserAgain',
          data:{uid:mid,nick_name:nick_name,header:header,start_time:start_time,end_time:end_time,reason:reason,cid:cid},
          dataType:'json',
          success:function(d){
              if(d.status=='ok'){
                  window.location.reload();
              }else{
                  alert(d.error_msg);
              }
          }
      });
  }
</script>

{template footer}
